package com.message.resp;

import com.constant.MessageType;
import com.message.DefaultMessage;
import lombok.Data;
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
@Data
public class ChatResp extends DefaultMessage {

    public static final int RECEIVER_NOT_ONLINE = 0;
    public static final int SEND_SUCCESS = 1;

    // 提示码：0：对方不在线；1：已成功发送
    private Integer code;
    private String tips;

    // 谁发送的消息
    private String fromUser;

    // 聊天内容
    private String chatContent;

    private String receiverName;

    public static ChatResp sendSuccess() {
        return sendSuccess(null, null);
    }

    public static ChatResp sendSuccess(String formUser, String chatContent) {
        ChatResp chatResp = new ChatResp();


        chatResp.setCode(SEND_SUCCESS);
        chatResp.setTips("已成功发送");
        chatResp.setFromUser(formUser);
        chatResp.setChatContent(chatContent);

        return chatResp;
    }

    public static ChatResp receiverNotOnLine(String receiverName) {
        ChatResp chatResp = new ChatResp();

        chatResp.setCode(RECEIVER_NOT_ONLINE);
        chatResp.setTips("对方不在线");
        chatResp.setReceiverName(receiverName);

        return chatResp;
    }

    private ChatResp() {

    }

    @Override
    public int getMessageType() {
        return MessageType.CHAT_RESPONSE;
    }
}
